package pack1;

public class java4 {
    public static void main(String[] args) {
        int arry[]=new int[1229];
        int crry[]=new int[2];
        int b=0;
        int sum=0;
        double aver;
        for (int num = 2; num <= 10000; num++) {
            if (isPrime(num)) {
                arry[b]=num;
                sum=sum+num;
                b=b+1;
            }
        }
       aver=sum*1.0/b;;
        for (int i = 0; i < 1229; i++) {
            if (arry[i] > 1000) {
                crry[0] = arry[i];
                break;
            }
        }
            for (int j = 0; j < 1229; j++) {
                if(arry[j]>8000){
                    crry[1]=arry[j-1];
                    break;
                }
            }
        System.out.println("aver"+"="+aver);
        System.out.println(crry[1]);
        System.out.println(crry[0]);
    }

    // 判断一个数是否为素数的辅助方法
    public static boolean isPrime(int number) {
        if (number <= 1) {
            return false;
        }
        for (int i = 2; i * i <= number; i++) {
            if (number % i == 0) {
                return false;
            }
        }
        return true;
    }
}


